package com.fyy.netty.chapter02.c2;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @Author fyy
 * @Description
 * @Date 2021/4/27 9:57
 */
@Slf4j
public class JDKFutureTest {

    public static void main(String[] args) throws Exception {
        //创建线程池
        ExecutorService service = Executors.newFixedThreadPool(2);
        //提交任务
        Future<Integer> future = service.submit(() -> {
            log.info("等待计算结果... ...");
            Thread.sleep(1000);
            return 50;
        });

        //通过future获取数据,get会阻塞
        log.info("获取计算结果:{}",future.get());




    }

}
